package com.purchase.ml.utils;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.UUID;

/**
 * Created by kyyang on 2021/1/10 16:16
 */
public class StringUtils {

    public static String getUUID(){
        return UUID.randomUUID().toString().replace("-","");
    }

    public static String generateCode(int num){
        String randomCode = "";
        // 用字符数组的方式随机
        String model = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        char[] m = model.toCharArray();
        for (int j = 0; j < num+1; j++) {
            char c = m[(int) (Math.random() * 36)];
            // 保证六位随机数之间没有重复的
            if (randomCode.contains(String.valueOf(c))) {
                j--;
                continue;
            }
            randomCode = randomCode + c;
        }
        return randomCode;
    }






}
